#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：pythonProject2 
@File    ：ex2.py
@Author  ：beibei
@Date    ：2023/12/22 3:30 PM 
'''
import socket
import time

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # SOCK_STREAM TCP的套接字  UDP SOCK_DGRAM
server_address = ("127.0.0.1", 8991)
client_socket.connect(server_address)
try:
    client_socket.sendall('吴亦凡'.encode('utf-8'))
    res = client_socket.recv(1024).decode('utf-8')
    print(res)
    time.sleep(1)
    client_socket.sendall('蔡徐坤'.encode('utf-8'))
    res = client_socket.recv(1024).decode('utf-8')
    print(res)
    time.sleep(7)
    client_socket.sendall('蔡徐坤'.encode('utf-8'))
    res = client_socket.recv(1024).decode('utf-8')
    print(res)
    client_socket.sendall('close'.encode('utf-8'))
    res = client_socket.recv(1024).decode('utf-8')
    print(res)
    client_socket.close()
except ConnectionAbortedError:
    print('会话被断开')